<template>
   <div class="carcontral">
       <transition name="move">
           <div class="crat-decrease " v-show="food.count>0" @click.stop.prevent="decreaseCart()">
                <span class="inner icon-remove_circle_outline"></span>
           </div>
       </transition>
       <div class="cart-count" v-show="food.count>0">{{food.count}}</div>
       <div class="cart-add icon-add_circle" @click.stop.prevent="addCart()"></div>
   </div>
</template>
<script>
export default {
  props: {
    food: {
      type: Object
    }
  },
  methods: {
    addCart() {
      console.log(12);
      if (!this.food.count) {
        // this.food.count=1
        this.$set(this.food, "count", 1);
      } else {
        this.food.count++;
      }
    },
    decreaseCart() {
      if (this.food.count) {
        this.food.count--;
      }
    }
  }
};
</script>
<style lang="stylus" scoped>
.carcontral {
    .crat-decrease {
        display: inline-block;
        padding: 6px;
        transition: all 0.4s linear;
        .inner {
            display: inline-block;
            line-height: 24px;
            font-size: 24px;
            color: rgb(0, 160, 220);
        }
    }
    .move-enter-active, .move-leave-active {
        transition: opacity .5s;
    }
    .move-enter, .move-leave-to /* .fade-leave-active below version 2.1.8 */ {
        opacity: 0;
    }

    .cart-count {
        display: inline-block;
        vertical-align: top;
        width: 12px;
        padding-top: 6px;
        line-height: 24px;
        text-align: center;
        font-size: 10px;
        color: rgb(147, 153, 159);
    }

    .cart-add {
        display: inline-block;
        padding: 6px;
        line-height: 24px;
        font-size: 24px;
        color: rgb(0, 160, 220);
    }
}
</style>

